// 任务详情页面相关的类型定义

export interface GitScanStatistics {
  repositoryInfo: {
    branch: string;
    commits: number;
    authors: number;
    lastUpdate: string;
    platform?: string;
  };
  scanCoverage: {
    coverageRate: number;
    ignoredFiles: number;
    totalFiles: number;
  };
  fileStatistics: {
    sqlFiles: number;
    javaFiles: number;
    xmlFiles: number;
    otherFiles: number;
  };
  sqlStatistics: {
    totalSqlStatements: number;
    rulesMatched: number;
    extractionTime?: number;
  };
}

export interface DatabaseScanStatistics {
  connectionInfo: {
    dbType: string;
    version: string;
    host: string;
    port: number;
    database: string;
    latency?: number;
    status: 'connected' | 'disconnected' | 'error';
  };
  extractionResults: {
    totalTables: number;
    totalIndexes: number;
    totalViews: number;
    totalProcedures: number;
    totalFunctions?: number;
  };
  ddlStatistics: {
    createStatements: number;
    alterStatements: number;
    dropStatements: number;
    indexStatements: number;
    totalStatements: number;
  };
  scanScope: {
    database: string;
    scannedTables: number;
    totalTables: number;
    extractionTime?: number;
  };
}

export interface MixedScanStatistics {
  gitStats: GitScanStatistics;
  dbStats: DatabaseScanStatistics;
  combined: {
    totalSqlStatements: number;
    gitCompletionRate: number;
    dbCompletionRate: number;
    overallProgress: number;
  };
}

export interface TaskExecutionStatus {
  canStart: boolean;
  canPause: boolean;
  canCancel: boolean;
  canRetry: boolean;
  canDownload: boolean;
}

export interface ProblemStatistics {
  total: number;
  high: number;
  medium: number;
  low: number;
  info: number;
  aiAnalyzed: number;
  ruleAnalyzed: number;
  categories: {
    syntax: number;
    function: number;
    datatype: number;
    performance: number;
    compatibility: number;
  };
  sqlStatements: {
    totalStatements: number;
    problemStatements: number;
    problemRate: number;
  };
}

// 扩展现有的ScanTaskResponse类型
export interface EnhancedScanTaskResponse {
  // 原有字段保持不变
  id: number;
  taskName: string;
  taskType: string;
  status: string;
  progress: number;
  projectId?: number;
  projectName?: string;
  branchName?: string;
  userId?: number;
  username?: string;
  description?: string;
  config?: any;
  extractionStats?: any;
  startTime?: string;
  endTime?: string;
  errorMessage?: string;
  reportPath?: string;
  createdAt: string;
  updatedAt?: string;
  retryCount?: number;
  maxRetryCount?: number;
  lastRetryTime?: string;
  canRetry?: boolean;
  
  // 后端增强显示字段
  analysisEngineDisplay?: string;  // "AI引擎" | "规则引擎" | "混合模式" 
  dataSourceDisplay?: string;      // "ORACLE: 168.63.18.127:1521/servdb"
  sourceDbType?: string;           // "ORACLE"
  targetDbType?: string;           // "GOLDENDB"
  aiEnhancementEnabled?: boolean;  // 是否启用AI增强分析
  
  // 新增的统计信息字段
  gitStatistics?: GitScanStatistics;
  databaseStatistics?: DatabaseScanStatistics;
  mixedStatistics?: MixedScanStatistics;
  executionStatus?: TaskExecutionStatus;
  problemStatistics?: ProblemStatistics;
}